import sys
import numpy as np

def verify_result(output_path, golden_path):
    # 读取数据：输出和黄金数据均为形状(1,)的int8
    output = np.fromfile(output_path, dtype=np.int8)
    golden = np.fromfile(golden_path, dtype=np.int8)
    
    # 检查形状是否为(1,)
    if output.shape != (1,) or golden.shape != (1,):
        print(f"Shape mismatch - output: {output.shape}, golden: {golden.shape} (expected (1,))")
        return False
    
    # 检查值是否一致
    if output[0] != golden[0]:
        print(f"Value mismatch - expected: {golden[0]}, actual: {output[0]}")
        return False
    
    return True


if __name__ == '__main__':
    try:
        if len(sys.argv) != 3:
            print("Usage: python verify_result.py <output_out.bin> <golden.bin>")
            sys.exit(1)
            
        res = verify_result(sys.argv[1], sys.argv[2])
        if not res:
            raise ValueError("[ERROR] result error")
        else:
            print("test pass")
    except Exception as e:
        print(e)
        sys.exit(1)